<extend name="$_home_public_layout"/>

<block name="style">
    <style type="text/css">
        .is_read,
        .is_read a {
            color: #ccc;
        }
        .toolbar {
            margin: 15px 0;
        }
    </style>
</block>

<block name="script">
    <script type="text/javascript">
        $(function(){
            //全选/反选/单选的实现
            $(".check-all").click(function() {
                $(".ids").prop("checked", this.checked);
            });

            $(".ids").click(function() {
                var option = $(".ids");
                option.each(function() {
                    if (!this.checked) {
                        $(".check-all").prop("checked", false);
                        return false;
                    } else {
                        $(".check-all").prop("checked", true);
                    }
                });
            });
        })
    </script>
</block>

<block name="main">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-md-3">
                <include file="$_user_center_side" />
            </div>
            <div class="col-xs-12 col-md-9">
                <div class="panel">
                    <div class="panel-body">
                        <ul class="nav-tabs nav">
                            <volist name="message_type" id="type">
                                <li class="<php>if($current_type == $key) echo 'active';</php>">
                                    <a href="{:U('', array('type' => $key))}">{$type} <span class="badge badge-danger">{$new_message_type[$key]}</span></a>
                                </li>
                            </volist>
                        </ul>
                        <div class="toolbar">
                            <a class="btn btn-info ajax-post" target-form="ids" href="{:U('readAll', array('type' => $current_type))}">设为已读</a>
                        </div>
                        <div class="tab-content">
                            <div class="builder-table">
                                <div class="panel panel-default">
                                    <table class="table table-bordered table-responsive table-striped table-hover">
                                        <thead>
                                            <tr>
                                                <th><input class="check-all" type="checkbox"></th>
                                                <th>消息</th>
                                                <th>时间</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <volist name="message_list" id="vo">
                                                <tr>
                                                    <td><input class="ids" type="checkbox" value="{$vo.id}" name="ids[]"></td>
                                                    <td><span class="<php>if($vo['is_read']){echo 'is_read';}</php>">{$vo.title}</span></td>
                                                    <td>{$vo.create_time|time_format}</td>
                                                </tr>
                                            </volist>
                                            <empty name="message_list">
                                                <tr class="builder-data-empty">
                                                    <td class="text-center empty-info" colspan="3">
                                                        <i class="fa fa-database"></i> 暂时没有消息<br>
                                                    </td>
                                                </tr>
                                            </empty>
                                        </tbody>
                                    </table>
                                </div>
                                <notempty name="page">
                                    <ul class="pagination">{$page}</ul>
                                </notempty>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
